home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Sound / DelfMPEG / src / PCM.a56 < prev    next >
Text File  |  2000-05-16  |  3KB  |  185 lines

  1. ;*****************************************************************************
  2. ;
  3. ;    DelfMPEG - MPEG audio player for Delfina DSP
  4. ;    Copyright (C) 1999, 2000  Michael Henke
  5. ;
  6. ;    This program is free software; you can redistribute it and/or modify
  7. ;    it under the terms of the GNU General Public License as published by
  8. ;    the Free Software Foundation; either version 2 of the License, or
  9. ;    (at your option) any later version.
  10. ;
  11. ;    This program is distributed in the hope that it will be useful,
  12. ;    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ;    GNU General Public License for more details.
  15. ;
  16. ;    You should have received a copy of the GNU General Public License
  17. ;    along with this program; if not, write to the Free Software
  18. ;    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. ;
  20. ;*****************************************************************************
  21.  
  22.  
  23.  
  24.  
  25. ;Delfina object DSP56K_PCM
  26. ;memory map (for Amiga access)
  27. ;
  28. ; prog
  29. ;   0 .. init (x1=mono, x0=volume, y1=freq, y0=/)
  30. ;  +2 .. mute (x1=/, x0=/, y1=/, y0=/)
  31. ;  +4 .. DelfModule
  32. ;
  33. ; xdata
  34. ;   /
  35. ;
  36. ; ydata
  37. ;   0 .. amybuf (Amiga read)
  38.  
  39.  
  40.  
  41.  
  42. DELFINA_SAMPLES    equ    1152
  43.  
  44.  
  45.     include 'delfequ.inc'
  46.  
  47.     org    p:
  48.  
  49. int_key
  50.  
  51. ;->prog
  52.     jmp    init
  53.  
  54. ;->prog+2
  55.     jmp    mute
  56.  
  57.  
  58. ;->prog+4
  59.  
  60. ;***********************************
  61. ;* play routine
  62. ;*
  63. ;* r1=list of play buffers
  64.  
  65. ;****    sampling rate conversion
  66.     move    y:(r1),r4        ;r4=output buf
  67.     move    r4,r7            ;r7=copy of r4
  68.     move    #rateconv,r3        ;r3=rateconv structure
  69.     move    x:bufptr,r6        ;r6=old bufptr
  70.  
  71.     movec    #DELFINA_SAMPLES*2-1,m2 ;m2=input buffer mask
  72.     jsr    <delf_playrate        ;rate conversion
  73.  
  74.  
  75. ;****    duplicate left channel for mono output
  76.     movec    m0,m7            ;#$ffff
  77.     move    y:mono,b
  78.     tst    b    r7,r0
  79.     jeq    not_mono
  80.     move    r7,n7
  81.     move    x:(r0)+,a
  82.     rep    #127
  83.     move    x:(r0)+,a    a,y:(r7)+
  84.     move    a,y:(r7)
  85.     move    n7,r7
  86. not_mono
  87.  
  88.  
  89. ;****    volume adjustment
  90.     move    y:volume,x1
  91.     move    #<$40,a            ;0.5 = 100%
  92.     cmp    x1,a    r7,r0
  93.     jeq    no_volume
  94.  
  95.     ori    #$08,mr                    ;SCALE UP mode
  96.     movec    m0,m5            ;#$ffff
  97.     move    r7,r5
  98.     move    r7,r1
  99.  
  100.     move            x:(r0)+,x0    y:(r5)+,y0
  101.     mpyr    x0,x1,a        x:(r0)+,x0
  102.     mpyr    y0,x1,b        a,x:(r1)+    y:(r5)+,y0
  103.     do    #127,volume_loop
  104.     mpyr    x0,x1,a        x:(r0)+,x0    b,y:(r7)+
  105.     mpyr    y0,x1,b        a,x:(r1)+    y:(r5)+,y0
  106. volume_loop
  107.     move                    b,y:(r7)+
  108.  
  109.     andi    #$f3,mr                    ;NO SCALING mode
  110. no_volume
  111.     
  112.  
  113. ;****    double buffering
  114.     move    r6,y1            ;y1=old pointer
  115.     move    y:buf2,b        ;b= start of buf2
  116.     cmp    y1,b    r2,y0        ;y0=new pointer
  117.     jle    dbuf_buf2
  118.     cmp    y0,b    y:buf1,x0
  119.     jgt    dbuf_skip
  120. dbuf_int
  121.     move    x0,y:amybuf        ;tell amiga the new buffer
  122.     move    #int_key,a0
  123.     move    #causeqw,r0
  124.     jmp    <delf_causeq        ;interrupt and exit
  125. dbuf_buf2
  126.     cmp    y0,b    b,x0
  127.     jgt    dbuf_int
  128. dbuf_skip
  129.     rts
  130.  
  131.  
  132.  
  133. ;***********************************
  134. ;* init stuff
  135. ;*
  136. ;* x1=mono
  137. ;* x0=volume
  138. ;* y1=freq
  139. ;* y0=/
  140. init
  141.     move    x1,y:mono
  142.     move    x0,y:volume
  143.     move    y1,x:freq
  144.     rts
  145.  
  146.  
  147. ;***********************************
  148. ;* clear current buffer (pause mode)
  149. ;*
  150. ;* x1=/
  151. ;* x0=/
  152. ;* y1=/
  153. ;* y0=/
  154. mute
  155.     clr    a    y:amybuf,r0
  156.     rep    #DELFINA_SAMPLES
  157.     move    a,l:(r0)+
  158.     move    a,x0
  159.     rts
  160.  
  161.  
  162.  
  163.  
  164.     org    l:
  165.     align    4096        ;must be >= DELFINA_SAMPLES*2
  166. buf    ds    DELFINA_SAMPLES*2
  167.  
  168.  
  169.     org    x:
  170. causeqw    dc    0,0
  171. rateconv
  172. freq    dc    0
  173. bufptr    dc    buf
  174.     ds    4
  175.     
  176.     org    y:
  177. ;->ydata
  178. amybuf    dc    buf
  179.  
  180. mono    dc    0
  181. volume    dc    0.5
  182.  
  183. buf1    dc    buf
  184. buf2    dc    buf+DELFINA_SAMPLES
  185.